<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib uri="http://v1.com/pn" prefix="v1" %>
<html>
<head>
<title>log | admin</title>

<style> 
  .black_overlay{  
  display: none;  position: absolute;  
  top: 0%;  left: 0%;  width: 100%;  height: 100%;  
  background-color: black;  z-index:1001;  -moz-opacity: 0.8;  opacity:.80;  filter: alpha(opacity=80);  } 
  .white_content {  
  display: none;  position: absolute;  
  top: 20%;  left: 20%;  width: 70%;  height: 70%;  
  padding: 16px;  border: 4px solid green;  background-color: white;  z-index:1002;  overflow: auto;  }  
</style> 
<script type="text/javascript">
function showStackTrace(t){
	document.getElementById('light1').style.display='block';
	document.getElementById('stackTrace').value=document.getElementById("stackTrace_"+t).innerHTML;
}

function gotoPage(a){
	document.forms[0].action+="method.search=&page="+a;
	document.forms[0].submit();
}

function remove(a){
	document.forms[0].action+="method.delete=&page="+a;
	document.forms[0].submit();
	
}
</script>
</head>

<body>
<c:if test="${not empty message}">
	<font color="red"><c:out value="${message}" escapeXml="false"></c:out></font>
</c:if>
<form action="./log.html?" method="post">
from:<input type="text" name="from" value="${from}">~
to:<input type="text" name="to" value="${to}"><br>(yyyy-MM-dd HH:mm:ss)<br>
level:<input type="text" name="level" value="${level}"><br>
source:<input type="text" name="source" value="${source}"><br>

<input type="submit" value="search" name="method.search"> 
<c:if test="${not empty logs}">
<input type="submit" value="delete" onclick="remove(${pageinfo.pageNo})"> 
</c:if>
</form>

<table width="80%" align="center" bordercolor="gray">
<c:forEach items="${logs}" var="log" varStatus="status">
<tr>
	<td align="left" width="5%">
		<c:choose>
			<c:when test="${log['level'] == 'ERROR'}">
				<font color="red"><c:out value="${log['level']}"></c:out></font>
			</c:when>
			<c:when test="${log['level'] == 'WARN'}">
				<font color="orange"><c:out value="${log['level']}"></c:out></font>
			</c:when>
			<c:when test="${log['level'] == 'INFO'}">
				<font color="green"><c:out value="${log['level']}"></c:out></font>
			</c:when>
			<c:when test="${log['level'] == 'DEBUG'}">
				<font color="gray"><c:out value="${log['level']}"></c:out></font>
			</c:when>
			<c:otherwise>
				<font color="blue"><c:out value="${log['level']}"></c:out></font>
			</c:otherwise>
		</c:choose>
	</td>
	<td align="left" width="5%">
		<c:out value="${log['source']}"></c:out>
	</td>
	<td align="left" width="15%">
		<fmt:formatDate value="${log['timestamp']}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>
	</td>
	<td align="left" width="70%">
		<c:out value="${log['message']}"></c:out>
	</td>
	<td align="left" width="5%">&nbsp;
		<c:if test="${not empty log['stackTrace']}">
		<div id="stackTrace_${status.index}" style="display: none;"><c:out value="${log['stackTrace']}"/></div>
		<a href="#" onclick="showStackTrace(${status.index})">stackTrace</a>
		</c:if>
	</td>
</tr>
</c:forEach>
</table>
<v1:pn name="pageinfo" onclick="gotoPage({0})"></v1:pn>

	<div id="light1" class="white_content">
		<table width="100%">
			<tr>
				<td align="right"><a href="javascript:void(0)"
					onclick="document.getElementById('light1').style.display='none'">
						X</a>
				</td>
			</tr>
			<tr>
				<td>
					<textarea id="stackTrace" readonly="readonly"   cols="140" rows="35"></textarea>
				</td>
			</tr>
		</table>
	</div>
</body>
</html>
